package domain;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class UrlJSON {
    public JSONObject json = new JSONObject();
    private final File URL = new File("C:\\Users\\shuixi\\Desktop\\PetStore\\web\\json\\url.json");

    public UrlJSON(){
        try(FileInputStream fileInputStream = new FileInputStream(URL)) {
            int size = fileInputStream.available();
            byte[] buffer = new byte[size];
            fileInputStream.read(buffer);
            String jsonString = new String(buffer, StandardCharsets.UTF_8);
            jsonString.replaceAll("\n", "");
            jsonString.replaceAll("\r", "");
            json = JSON.parseObject(jsonString);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
